package com.wuhan.template.module.find.activity;



import android.support.annotation.NonNull;
import android.util.Log;
import android.widget.TextView;

import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.wuhan.template.R;
import com.wuhan.template.base.BaseActivity;
import com.wuhan.template.constant.Urls;
import com.wuhan.template.module.find.adapter.ZhuantiListAdapter;
import com.wuhan.template.module.find.bean.AAA;
import com.wuhan.template.utils.EventMessage;
import com.wuhan.template.utils.OkHttpUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;


public class ZhuantiActivity extends BaseActivity{


    @BindView(R.id.pic_list)
    public PullToRefreshListView listView;
    @BindView(R.id.zt_back)
    TextView back;

    private List<AAA.ListBean> listBeans = new ArrayList<>();
    private ZhuantiListAdapter adapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_zhuanti_layout;
    }



    @OnClick(R.id.zt_back)
    public void back(){
        finish();
    }

    @Override
    protected void initViews() {

    }

    @Override
    protected void loadData() {
        OkHttpUtils.get(Urls.ZT,null);
    }

    @Override
    protected void postEventResult(@NonNull EventMessage message) {
        if (message.type.equals(Urls.ZT)){
            Gson gson = new Gson();
            AAA aaa = gson.fromJson(message.result, AAA.class);
            listBeans = aaa.getList();
            adapter = new ZhuantiListAdapter(getApplicationContext(),listBeans);
            listView.setAdapter(adapter);
        }

    }
}
